<template>
  <div class="all">
    <header>
      <div class="div">
        <img src="../../../assets/返回.png" @click="back()" alt="">
        <span class="solid" @click="back()">返回</span>
      </div>
      <div class="div">
        <span>医师建议</span>
      </div>
      <div class="div">
        <span class="solid" v-show="isDoctor=='true'" @click="doctorKeep()">保存</span>
      </div>
    </header>
    <div class="label">
      <a class="hengGang"></a>患者描述病情
    </div>
    <div class="textDiv">
      <textarea readonly v-model="illness_desc"></textarea>
    </div>
    <div class="label">
      <a class="hengGang"></a>患者病情相关资料
    </div>
    <div>
      <ul class="ulList">
        <li >
          <span class="li_label">被服务人信息</span>
          <span class="li_input">
            <input type="text" v-model="name" readonly placeholder="请选择被服务人">
            <img src="../../../assets/下弹灰@2x.png" alt="">
          </span>
        </li>
        <li >
          <span class="li_label">是否需要医生指导用药</span>
          <span class="li_input">
            <input type="text" v-model="isdoctorVal" readonly placeholder="请选择是或否">
            <img src="../../../assets/下弹灰@2x.png" alt="">
          </span>
        </li>
        <li v-show="isYoung == true">
          <span class="li_label">体重</span>
          <span class="li_input">
            <input type="text" v-model="weight" placeholder="请输入体重">
            kg
          </span>
        </li>
        <li >
          <span class="li_label">是否曾到医疗机构就诊</span>
          <span class="li_input">
            <input type="text" v-model="isHosVal"  readonly placeholder="请选择是或否">
            <img src="../../../assets/下弹灰@2x.png" alt="">
          </span>
        </li>
      </ul>
    </div>
    <button class="lookBtn" @click="LookHis()">查看患者相关资料</button>
<!--    <div class="label">-->
<!--      <a class="hengGang"></a>患者上传病情相关资料-->
<!--    </div>-->
<!--    <div style="background: white;padding: 0 10px;box-sizing: border-box">-->
<!--      <van-uploader :deletable="false" :max-count="Iimg.length" v-model="fileList" multiple />-->
<!--    </div>-->
    <div class="label" style="justify-content: space-between">
      <span style="display: flex;align-items: center"><a class="hengGang"></a>医生建议</span>
      <span style="color: #1DA4F2">常用语</span>
    </div>
    <div class="textDiv">
      <textarea
        :readonly="!isDoctor"
        :placeholder="placeJianyi"
        v-model="doc_advise">
      </textarea>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DoctorJianYi',
  data () {
    return {
      id: this.$route.query.id,
      illness_desc: '',
      doc_advise: '',
      Iimg: [],
      fileList: [],
      name: '',
      isdoctorVal: '',
      weight: '',
      isHosVal: '',
      isYoung: false,
      placeJianyi: '',
      isDoctor: this.$route.query.isDoctor
    }
  },
  mounted () {
    if (this.isDoctor == 'true') {
      this.placeJianyi = '请输入建议'
    }
    this.getData()
  },
  methods: {
    // 医生填写完建议保存
    doctorKeep () {
      this.$http.updateDocSuggest({id: this.id, doc_advise: this.doc_advise})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.$router.history.go(-1)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 查看相关资料
    LookHis () {
      this.$router.push({path: '/tuWenUpload'})
    },
    // 获取患者历史信息
    getData () {
      this.$http.findOneInquiry({id: this.id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.illness_desc = res.data.data.illness_desc
            this.doc_advise = res.data.data.doc_advise
            if (res.data.data.age < 6) {
              this.isYoung = true
            }
            this.Iimg = res.data.data.Iimg
            for (var i = 0; i < this.Iimg.length; i++) {
              var obj = { url: this.Iimg[i].img_url, isImage: true }
              this.fileList.push(obj)
            }
            this.name = res.data.data.PATIENT_NAME
            if (res.data.data.is_doc_medical == 0) {
              this.isdoctorVal = '否'
            } else if (res.data.data.is_doc_medical == 1) {
              this.isdoctorVal = '是'
            }
            if (res.data.data.is_hos_visit == 0) {
              this.isHosVal = '否'
            } else if (res.data.data.is_hos_visit == 1) {
              this.isHosVal = '是'
            }
            this.weight = res.data.data.weight

            var fileList = []
            var imgList = []
            for (var i = 0; i < res.data.data.Iimg.length; i++) {
              var file = { url: res.data.data.Iimg[i].img_url, isImage: true }
              fileList.push(file)
              imgList.push(res.data.data.Iimg[i].img_url)
            }
            var jianChaList = []
            var jianYanList = []
            // 检查
            for (var i = 0; i < res.data.data.Clist.length; i++) {
              var jc = {
                id: res.data.data.Clist[i].id,
                xiangmu: res.data.data.Clist[i].xiangmu,
                show: false,
                money: res.data.data.Clist[i].money
              }
              jianChaList.push(jc)
            }
            for (var i = 0; i < res.data.data.Jlist.length; i++) {
              var jy = {
                id: res.data.data.Jlist[i].id,
                xiangmu: res.data.data.Jlist[i].xiangmu,
                show: false,
                money: res.data.data.Jlist[i].money
              }
              jianYanList.push(jy)
            }

            var obj = {
              jianChaList: jianChaList,
              jianYanList: jianYanList,
              menuIndex: 0,
              fileList: fileList,
              imgList: imgList,
              checkmoney: null,
              inspermoney: null,
              isJYdelBtn: false,
              isJCdelBtn: false,
              maxCount: res.data.data.Iimg.length,
              disable: true,
              PATIENT_USER_ID: res.data.data.PATIENT_USER_ID
            }
            sessionStorage.setItem('tuWenData', JSON.stringify(obj))
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    // 返回
    back () {
      this.$router.history.go(-1)
    }
  }
}
</script>

<style scoped>
  .all{
    width: 100%;
    height: 100%;
    overflow: auto;
    background: #FAF9FE;
  }
  header{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    font-family: "PingFang SC";
    background: white;
    position: sticky;
    top: 0;
    border-bottom: 1px solid #E5E5E5;
  }
  .div{
    width: 33%;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
  }
  .div:nth-child(1) img{
    width: 7px;
    height: 13px;
    margin: 0 5px 0 15px;
  }
  .div:nth-child(2){
    justify-content: center;
  }
  .div:nth-child(3){
    justify-content: flex-end;
  }
  .div:nth-child(3) span{
    margin-right: 15px;
  }
  .solid{
    color: #1DA4F2;
  }
  .hengGang{
    display: block;
    width: 2px;
    border-radius: 1px;
    height: 15px;
    background: #1DA4F2;
    margin-right: 5px;
  }
  .label{
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-sizing: border-box;
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: bold;
    background: white;
  }
  .textDiv{
    width: 100%;
    background: white;
  }
  textarea{
    width: 95%;
    height: 130px;
    resize: none;
    background: #FAF9FE;
    border-radius: 10px;
    border: none;
    margin: 0 2%;
    padding: 10px;
    box-sizing: border-box;

    font-size: 13px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #999999;
  }
  .ulList{
    width: 100%;
    background: white;
    padding:  0 15px;
    box-sizing: border-box;
  }
  .ulList li{
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #E5E5E5;
  }
  .li_label{
    font-size: 15px;
    font-family: PingFang SC;
    font-weight: 500;
    color: #333333;
  }
  .li_input img{
    width: 13px;
    height: 7px;
  }
  .li_input input{
    width: 110px;
    text-align: right;
    border: none;
    font-size: 15px;
  }
  .lookBtn{
    width: 95%;
    height: 44px;
    background: linear-gradient(90deg, #1DA3F2 0%, #1DC7F2 100%);
    border-radius: 22px;
    margin: 10px 2%;
    border: 1px solid #1DA4F2;
    color: white;
    font-size: 17px;
    font-family: "PingFang SC";
    font-weight: bold;
  }
</style>
